{extend name="public:base" /}
{block name="js"}
<script type="text/javascript" src="__STATIC__/js/plugins/chosen/chosen.jquery.js"></script>

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <form method="post" id="user-form" class="ajax-form"
                          action="{:url('edit',[],'json')}?oldId=$row.id">
                        <input name="uid" type="hidden">
                        <input name="__token__" type="hidden" value="{$__token__}">
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">印章名称</label>
                                <div class="col-sm-3" autocomplete="off">
                                    <input type="text" name="name"
                                           value="{$row.name}"
                                           class="form-control required-validate" placeholder="请输入印章名称">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 bg-danger col-form-label">旧设备编号</label>
                                <div class="col-sm-3">
                                    <input type="text" name="old_number" class="form-control" disabled
                                           value="{$row.number}"
                                           placeholder="设备编号">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 bg-primary col-form-label">新设备编号</label>
                                <div class="col-sm-3">
                                    <input type="text" name="number" class="form-control required-validate"
                                           value=""
                                           placeholder="新设备编号">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">印章类型</label>
                                <div class="col-sm-3">
                                    <select class="form-control m-b" name="seal_type">
                                        {volist name="sealTypes" id="entity"}
                                        <option value="{$entity.id}" {eq name="row.seal_type" value="$entity.id"
                                                }selected{
                                        /eq}>{$entity.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">印章状态</label>
                                <div class="col-sm-3">
                                    <select class="form-control m-b" name="status">
                                        {volist name="sealStatuses" id="entity"}
                                        <option value="{$entity.id}" {eq name="row.status" value="$entity.id" }selected{
                                        /eq}>{$entity.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">所属部门</label>
                                <div class="col-sm-3">
                                    {volist name="departments" id="entity" key="key"}
                                    <div class="i-checks">
                                        <label>
                                            <input type="checkbox" name="department[]" {if
                                                   condition="in_array($entity.id,$companyIds)" } checked {/if}
                                            value="{$entity.id}"> <i></i>
                                            {$entity.name}
                                        </label>
                                    </div>
                                    {/volist}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item data_1">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">收到日期</label>
                                <div class="input-group col-sm-3 date">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control datepicker" name="date_received"
                                           value="{:date('Y-m-d',time())}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item data_1">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">过期日期</label>
                                <div class="input-group col-sm-3 date">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control datepicker" name="expired_time"
                                           value="{$row.expired_time_txt}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">印章描述</label>
                                <div class="col-sm-3">
                                    <textarea class="form-control" name="remark" rows="8">{$row.remark}</textarea>
                                    <span class="form-text m-b-none">这是说明文字这是说明文字这是说明文字这是说明文字</span>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">印章图片</label>
                                <div class="col-sm-8">
                                    <div style="position: relative;cursor: pointer;" class="sealImg">
                                        <input type="file" id="BannarImgId" name="BannarImgId">
                                        <input type="hidden" name="img" value="{$row.cover.id}">
                                        <img class="upload-file" src="{$row.cover.path}"
                                             style="width: 100px;height: 100px;">
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button type="button" class="btn btn-w-m btn-default back-page">返回</button>
                                <button type="submit" class="btn btn-w-m btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name='js'}
<script type="text/javascript" src="__PLUG__/kindeditor/kindeditor-all.js"></script>
<script>
    $(document).ready(function () {
        <!-- 实例化编辑器 -->

        laydate.render({
            calendar: true,
            elem: '.datepicker' //指定元素
        });

        function updateImg() {

            $('#BannarImgId').change(function () {
                var pic = $(this)[0].files[0];
                var formData = new FormData();
                var url = "{:url('UploadFile/uploadPicture',array('session_id'=>session_id()))}";
                formData.append('download', pic);
                $.ajax({
                    url: url,
                    type: "post",
                    data: formData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function (data) {
                        if (data.status === 1) {
                            //上传成功
                            var id = data.data[0].id;
                            var path = data.data[0].path;
                            $(".sealImg").find("img").attr("src", path);
                            $(".sealImg").find("input[type='hidden']").val(id);
                        } else {
                            layer.msg(data.info);
                        }
                    }
                });
            });
        }

        updateImg();
    })
</script>
{/block}
